<?php 
	require_once 'Mobile_Detect.php';
	require_once 'class.phpmailer.php';
	require_once 'class.db.php';

	//todo
	function f_isMobile(){
		$detect = new Mobile_Detect;
		$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
		return $deviceType;
	}
	
	function getCurLang(){
		if(isset($_GET['lang']) && ($_GET['lang']=='vi')) 
			$lang = 'vi';
		else 
			$lang = 'en';
		
		return $lang;
	}
	
	function languageDecode($code){
		$lang = $_GET['lang'];
		
		if($lang == '' || $lang == 'en')
			$lang = 'en-GB';
		else
			$lang = 'vi-VN';
		
		if(!isset($_COOKIE['WMC_OKT_LANG_EN'])){
			$en_ini_array = parse_ini_file("language/en-GB/en-GB.ini");
			//setcookie('WMC_OKT_LANG_EN',serialize($en_ini_array),time() + (86400 * 30));
		}
		
		if(!isset($_COOKIE['WMC_OKT_LANG_VI'])){
			$vi_ini_array = parse_ini_file("language/vi-VN/vi-VN.ini");
			//setcookie('WMC_OKT_LANG_VI',serialize($vi_ini_array),time() + (86400 * 30));
		}
		
		
		if($lang == 'en-GB'){
			$en_ini_array = $_COOKIE['WMC_OKT_LANG_EN'];
			//$en_ini_array = unserialize($en_ini_array);
			$en_ini_array = parse_ini_file("language/en-GB/en-GB.ini");
			//print_r($en_ini_array);
			
			return $en_ini_array[$code];
		}
		
		if($lang == 'vi-VN'){
			$vi_ini_array = $_COOKIE['WMC_OKT_LANG_VI'];
			//$vi_ini_array = unserialize($vi_ini_array);
			$vi_ini_array = parse_ini_file("language/vi-VN/vi-VN.ini");
			return $vi_ini_array[$code];
		}
		
	}
	
?>